/*
 * @o: ========================================================
 * @Created By: VsCode
 * @Author: Fu
 * @name: 管理员控制器
 * @LastEditTime: 2021-05-13 11:41:00
 * @Date: 2021-05-11 10:43:34
 * @u: ========================================================
 */
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/index' + location.search,
                    // add_url: 'order/add',
                    // edit_url: 'order/edit',
                    // del_url: 'order/del',
                    multi_url: 'order/multi',
                    // import_url: 'order/import',
                    table: 'order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'order_number', title: __('Order_number'), operate: 'LIKE'},
                        {field: 'user.nickname', title: __('用户名')},
                        // {field: 'address_id', title: __('Address_id')},
                        // {field: 'address.id', title: __('Address.id')},
                        {field: 'address.tel', title: __('Address.tel'), operate: 'LIKE'},
                        {field: 'address.username', title: __('Address.username'), operate: 'LIKE'},
                        {field: 'address.area', title: __('Address.area'), operate: 'LIKE'},
                        {field: 'address.street', title: __('Address.street'), operate: 'LIKE'},
                        {field: 'address.address', title: __('Address.address'), operate: 'LIKE'},
                        // {field: 'address.status', title: __('Address.status')},
                        // {field: 'address.user_id', title: __('Address.user_id')},
                        // {field: 'orderchild.id', title: __('Orderchild.id')},
                        // {field: 'orderchild.order_id', title: __('Orderchild.order_id')},
                        {field: 'orderchild.goods_name', title: __('商品名称')},
                        {field: 'orderchild.price', title: __('Orderchild.price')},
                        {field: 'orderchild.goods_num', title: __('Orderchild.goods_num')},
                        {field: 'order_stutas', title: __('Order_stutas'), searchList: {"1":__('Order_stutas 1'),"2":__('Order_stutas 2'),"3是":__('Order_stutas 3是'),"4":__('Order_stutas 4')}, formatter: Table.api.formatter.normal},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});